﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DataInput
{
    public class Field
    {
        protected String _fieldName;
        protected String _fieldLabel;
        protected bool canBeEmpty = true;
        private bool _forOutput = false;       
        protected Object value;

        public bool ForOutput
        {
            get { return _forOutput; }
            set { _forOutput = value; }
        }

        public Object Value
        {
            get { return this.value; }
            set { this.value = value; }
        }

        public Field()
        {
        }

        public Field(String fieldName, String fieldLabel, bool canBeEmpty, bool forOutput)
        {
            this._fieldName = fieldName;
            this._fieldLabel = fieldLabel;
            this.canBeEmpty = canBeEmpty;
            this._forOutput = forOutput;
        }

        public Field(String fieldName, String fieldLabel, bool canBeEmpty) : this ( fieldName, fieldLabel, canBeEmpty, false )
        {
        }

        public virtual Dictionary<String, Object> getOptions()
        {
            return null;
        }

        public Field(String fieldName, String fieldLabel, Object value, bool canBeEmpty) : this ( fieldName, fieldLabel, value, canBeEmpty, false )
        {
        }

        public Field(String fieldName, String fieldLabel, Object value, bool canBeEmpty, bool forOutput )
        {
            this._fieldName = fieldName;
            this._fieldLabel = fieldLabel;
            this.value = value;
            this.canBeEmpty = canBeEmpty;
            this._forOutput = forOutput;
        }

        public virtual bool isValid()
        {
            return !canBeEmpty ? value != null : true;
        }

        public String FieldLabel
        {
            get { return _fieldLabel; }
            set { _fieldLabel = value; }
        }

        public String FieldName
        {
            get { return _fieldName; }
            set { _fieldName = value; }
        }
    }    
}
